<!DOCTYPE html>
<html>
<head>
<title>treatInfoIframe.html</title>

<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">

<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

</head>
<style type="text/css">
body {
	width: 100%;
	height: 100%;
	background: #fff;
}

select {
	height: 38px;
	line-height: 1.3;
	line-height: 38px\9;
	border-width: 1px;
	border-style: solid;
	background-color: #fff;
	border-radius: 2px;
	width: 100%;
}

#btn_search {
	margin-top: 8px;
	margin-left: -25px;
}

.row {
	margin-top: 10px;
}

.content_center {
	text-align: center;
}
/*表格样式*/
</style>
<link rel="stylesheet" href="/Hospital/lib/layui-v2.1.6/layui/css/layui.css" media="all">
<body>
	<div id="div_clientTable" class="layui-form layui-container" style="">
		<div id="div_client" class="layui-row row">
			<div class="layui-col-xs3 layui-col-xs-offset1 layui-col-sm2 layui-col-sm-offset1 layui-col-md2 layui-col-md-offset2">
				<span class="layui-form-label">所属病人: </span>
			</div>
			<div class="layui-col-xs5 layui-col-sm3 layui-col-md2">
				<input id="client" class="layui-input" type="text" placeholder="病人姓名">
			</div>
			<!-- <div class="layui-col-xs2 layui-col-xs-offset1 layui-col-sm1 layui-col-sm-offset1 layui-col-md1 layui-col-md-offset1">
				<button id="btn_search" class="layui-btn layui-btn-mini">
					<i class="layui-icon">&#xe615;</i> 查询
				</button>
			</div> -->
		</div>
		
		<div class="layui-row row content_center">
			<table class="layui-table" lay-skin="line row" id="tb_clientTable" lay-filter="tableListen" lay-even></table>
		</div>
	</div>
</body>
<script src="/Hospital/lib/jquery.min.js" charset="utf-8"></script>
<script src="/Hospital/lib/layui-v2.1.6/layui/layui.js" charset="utf-8"></script>
<script>
	var client ={};//选中客户

	layui.use([ 'table' ], function() {
		var table = layui.table;
		var $ = layui.jquery;
		initFrame();

		function initFrame() {
			btnSearchEvent();//搜索按钮监听事件
		}
		
		renderTable([]);
		
		//搜索按钮监听事件
		function btnSearchEvent() {
			$("#btn_search").on("click", function() {
				var param = {
					searchParam : $("#client").val()
				};
				initTable(param);
			});
			
			$('#client').change(function() {
				var param = {
					searchParam : $("#client").val()
				};
				initTable(param);
			});
		}
		//param:搜索参数
		function initTable(param) {
			//console.log("initTable.param");
			//console.log(param);
			$.ajax({
				type : 'post',
				url : "/Hospital/userController/searchClient",
				data : param,
				success : function(response) {
					if(response.code != 200 && response.code != 414) {
						console.error(response);
						return;
					}
					//console.log("initTable.response");
					//console.log(response);
					renderTable(response.result);
					
				}
			});
			
		}
		
		function renderTable(data) {
			var tableWidth = $(document.body).width() * 0.2;	//数据表格大列宽
			var tableHeight = $(document.body).height() * 0.780; //数据表格高度
			var rightFixed = $(document.body).width() * 0.13;  //数据表格操作宽度
			var sexWidth = $(document.body).width() * 0.15;	//数据表格小列宽度
			var identityWidth = $(document.body).width() * 0.35;
			
			table.render({
				id : "tb_clientTable",
				elem : "#tb_clientTable",
				center : true,
				page : true, //分页
				limit : 10, //每页显示条数
				height: 'full-130',				
				cols : [ [ 
							{field : 'name',width : tableWidth,title : '姓名',align : 'center',event : "clickRow"},
							{field : 'identity',width : identityWidth,title : '身份证',align : 'center',event : "clickRow"}, 
							{field : 'sex',width : sexWidth,title : '性别',align : 'center',event : "clickRow"}, 
							{field : 'birthdate',width : tableWidth,title : '出身日期',align : 'center',event : "clickRow"}, 
						] ],
				data : data
			});
			//监听单元格事件
			table.on('tool(tableListen)', function(obj){
				var data = obj.data;
				if(obj.event === 'clickRow'){	//行点击事件
					client = data;
				}
			});
		}
		
	});

	//设置病人信息为空
	function setClinetInfoEmpty() {
		$("#clientId").val("");
		$("#name").val("");
		$("#sex").val("");
		$("#phone").val("");
	}
	
	//判断对象是否为空
	function isEmptyObject ( obj ) {
		for ( var name in obj ) {
			return false;
		}
		return true;
	} 
	
	//获取窗口数据
	function initParam() {
		if(isEmptyObject(client)) {
			return {clientId : ""};
		}
		
		var param = {};
		param = {
			clientId : client.clientId,
		};
		return param;
	}
</script>
</html>
